/*
 * Copyright © 2011 SenseForce.com.
 * The Software shall be used for Good, not Evil.
 */

package com.jai2me.assist;

import java.util.Calendar;
import java.util.Date;

/**
 * little tools
 * @author jcccn
 * @site http://www.senseforce.com/
 */
public class JAITools {

    /**
     * check whether one string is null or empty
     * @param string
     * @return
     */
    public static boolean isNullOrEmpty(String string) {
        if (string == null || "".equals(string.trim())) {
            return true;
        }
        return false;
    }

    /**
     * sleep for some milliseconds
     * @param time
     * @return
     */
    public static boolean sleep(long time) {
        try {
            Thread.sleep(time);
            return true;
        } catch (InterruptedException ex) {
            return false;
        }
    }

    /**
     * get the time string with the format like this:13:27:55
     * @return
     */
    public static String getNowTime() {
        Calendar calendar = Calendar.getInstance();
	calendar.setTime(new Date());
	String timeString="";
	int hour      = calendar.get(Calendar.HOUR_OF_DAY);
	int minute    = calendar.get(Calendar.MINUTE);
	int second    = calendar.get(Calendar.SECOND);

	if(calendar.get(Calendar.AM_PM) == Calendar.PM) {
            hour += 0;
        }
	else {
            hour += 8;
        }
	timeString+= " "+hour;
	timeString+= ":"+minute;
	timeString+= ":"+second;
	return timeString;
    }



}
